import request from "@/utils/request";

// 将分页+搜索条件作为查询参数传递
export function getAnnouncementList(params: any) {
    return request({
        url: '/api/announcements',
        method: 'get',
        params
    });
}

export function getAnnouncementDetail(id:number){
    return request({
        url: `/api/announcements/${id}`,
        method: 'GET'
    });
}

export function createAnnouncement(data:any){
    return request({
        url:'/api/announcements',
        method: "post",
        data
    });
}

export function updateAnnouncement(data:any){
    return request({
        url: `/api/announcements/${data.id}`,
        method: 'put',
        data
    });
}

export function deleteAnnouncement(id:number){
    return request({
        url: `/api/announcements/${id}`,
        method: 'delete',
    });
}

export function batchDeleteAnnouncements(ids:number[]){
    return request({
        url: '/api/announcements/batch',
        method: "post",
        data:ids
    });
}

export function toggleTopStatus(data: { id: number; isTop: number }) {
    return request({
        url: '/api/announcements/top',
        method: 'post',
        data
    });
}


export function togglePublishStatus(data: { id: number; status: string }) {
    return request({
        url: '/api/announcements/status',
        method: 'post',
        data
    });
}

